<?php
define('ROOT',dirname($_SERVER['SCRIPT_FILENAME']));
require_once ROOT.'/core/yckit.config.php';
require_once ROOT.'/core/yckit.function.php';
require_once ROOT.'/core/yckit.version.php';
import('db');
$db=new db('182.50.133.147','uhuangse','CN159uh@csdn','uhuangse',false);
#数据库创建表
ini_set('memory_limit', '120M');
echo ROOT;
echo '<br/>';
$start_time=microtime(true);
$dir = 'C:/domains/2/';
$result=scandir($dir);
$index =0;
$sc =0;
foreach($result as $value){
	if($value != '.' && $value !='..'){
		if(strrchr($value,".") == ".txt"){
			$co = 0;
			$handle = fopen($dir.$value, "rb");//读取二进制文件时，需要将第二个参数设置成'rb'
			$sql = fread($handle, filesize ($dir.$value));
			fclose($handle);
			$segment = explode(";\r\n\r\n",$sql);
			echo 'exec ' . $dir.$value;
			foreach($segment as & $statement){
				$r = $db->query($statement);
				printf("Updated records:  %d<br/>", mysql_affected_rows()); 
				mysql_query("COMMIT");
				$sc +=1;
				$co +=1;
			}
			//echo 'exec ' . $dir.$value . ' | '. $co . '<br/>' ;
			$index +=1;
			unset($sql);
			unset($segment);
		}
	}
}
$end_time=microtime(true);
$time=$end_time-$start_time;
echo '<br/>' . $sc . '<br/>' .$index . '<br/>' . $time;
?>

